<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWxtjArticle extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //图文群发每日数据
        Schema::create('wxtj_article_summarys', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->string('msgid', 30)->default('')->comment('消息ID，由msg_data_id加_消息次序索引');
            $table->string('title', 200)->default('')->comment('图文消息的标题');
            $table->unsignedInteger('int_page_read_user')->default(0)->comment('图文页（点击群发图文卡片进入的页面）的阅读人数');
            $table->unsignedInteger('int_page_read_count')->default(0)->comment('图文页的阅读次数');
            $table->unsignedInteger('ori_page_read_user')->default(0)->comment('原文页（点击图文页“阅读原文”进入的页面）的阅读人数，无原文页时此处数据为0');
            $table->unsignedInteger('ori_page_read_count')->default(0)->comment('原文页的阅读次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('add_to_fav_user')->default(0)->comment('收藏的人数');
            $table->unsignedInteger('add_to_fav_count')->default(0)->comment('收藏的次数');
            $table->timestamps();
            $table->index(['msgid','ref_date'], 'index1');
        });
        //图文群发总数据
        Schema::create('wxtj_article_totals', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('文章群发出日期');
            $table->string('msgid', 30)->default('')->comment('消息ID，由msg_data_id加_消息次序索引');
            $table->string('stat_date', 20)->default('')->comment('数据统计日期');
            $table->string('title', 200)->default('')->comment('图文消息的标题');
            $table->unsignedInteger('target_user')->default(0)->comment('送达人数，一般约等于总粉丝数');
            $table->unsignedInteger('int_page_read_user')->default(0)->comment('图文页（点击群发图文卡片进入的页面）的阅读人数');
            $table->unsignedInteger('int_page_read_count')->default(0)->comment('图文页的阅读次数');
            $table->unsignedInteger('ori_page_read_user')->default(0)->comment('原文页（点击图文页“阅读原文”进入的页面）的阅读人数，无原文页时此处数据为0');
            $table->unsignedInteger('ori_page_read_count')->default(0)->comment('原文页的阅读次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('add_to_fav_user')->default(0)->comment('收藏的人数');
            $table->unsignedInteger('add_to_fav_count')->default(0)->comment('收藏的次数');
            $table->unsignedInteger('int_page_from_session_read_user')->default(0)->comment('公众号会话阅读人数');
            $table->unsignedInteger('int_page_from_session_read_count')->default(0)->comment('公众号会话阅读次数');
            $table->unsignedInteger('int_page_from_hist_msg_read_user')->default(0)->comment('历史消息页阅读人数');
            $table->unsignedInteger('int_page_from_hist_msg_read_count')->default(0)->comment('历史消息页阅读次数');
            $table->unsignedInteger('int_page_from_feed_read_user')->default(0)->comment('朋友圈阅读人数');
            $table->unsignedInteger('int_page_from_feed_read_count')->default(0)->comment('朋友圈阅读次数');
            $table->unsignedInteger('int_page_from_friends_read_user')->default(0)->comment('好友转发阅读人数');
            $table->unsignedInteger('int_page_from_friends_read_count')->default(0)->comment('好友转发阅读次数');
            $table->unsignedInteger('int_page_from_other_read_user')->default(0)->comment('其他场景阅读人数');
            $table->unsignedInteger('int_page_from_other_read_count')->default(0)->comment('其他场景阅读次数 ');
            $table->unsignedInteger('int_page_from_kanyikan_read_user')->default(0)->comment('看一看来源阅读人数');
            $table->unsignedInteger('int_page_from_kanyikan_read_count')->default(0)->comment('看一看来源阅读次数');
            $table->unsignedInteger('int_page_from_souyisou_read_user')->default(0)->comment('搜一搜来源阅读人数');
            $table->unsignedInteger('int_page_from_souyisou_read_count')->default(0)->comment('搜一搜来源阅读次');
            $table->unsignedInteger('feed_share_from_session_user')->default(0)->comment('公众号会话转发朋友圈人数');
            $table->unsignedInteger('feed_share_from_session_cnt')->default(0)->comment('公众号会话转发朋友圈次数');
            $table->unsignedInteger('feed_share_from_feed_user')->default(0)->comment('朋友圈转发朋友圈人数');
            $table->unsignedInteger('feed_share_from_feed_cnt')->default(0)->comment('朋友圈转发朋友圈次数 ');
            $table->unsignedInteger('feed_share_from_other_user')->default(0)->comment('其他场景转发朋友圈人数');
            $table->unsignedInteger('feed_share_from_other_cnt')->default(0)->comment('其他场景转发朋友圈次数');
            $table->timestamps();
            $table->index(['msgid','ref_date','stat_date'], 'index1');
        });
        //图文统计数据
        Schema::create('wxtj_article_userreads', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('int_page_read_user')->default(0)->comment('图文页（点击群发图文卡片进入的页面）的阅读人数');
            $table->unsignedInteger('int_page_read_count')->default(0)->comment('图文页的阅读次数');
            $table->unsignedInteger('ori_page_read_user')->default(0)->comment('原文页（点击图文页“阅读原文”进入的页面）的阅读人数，无原文页时此处数据为0');
            $table->unsignedInteger('ori_page_read_count')->default(0)->comment('原文页的阅读次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('add_to_fav_user')->default(0)->comment('收藏的人数');
            $table->unsignedInteger('add_to_fav_count')->default(0)->comment('收藏的次数');
            $table->timestamps();
            $table->index(['ref_date'], 'index1');
        });
        //图文统计分时数据
        Schema::create('wxtj_article_userreadhours', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->string('ref_hour', 10)->default('')->comment('数据的小时');
            $table->unsignedInteger('user_source')->default()->comment('');
            $table->unsignedInteger('int_page_read_user')->default(0)->comment('图文页（点击群发图文卡片进入的页面）的阅读人数');
            $table->unsignedInteger('int_page_read_count')->default(0)->comment('图文页的阅读次数');
            $table->unsignedInteger('ori_page_read_user')->default(0)->comment('原文页（点击图文页“阅读原文”进入的页面）的阅读人数，无原文页时此处数据为0');
            $table->unsignedInteger('ori_page_read_count')->default(0)->comment('原文页的阅读次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('add_to_fav_user')->default(0)->comment('收藏的人数');
            $table->unsignedInteger('add_to_fav_count')->default(0)->comment('收藏的次数');
            $table->timestamps();
            $table->index(['ref_date','ref_hour','user_source'], 'index1');
        });
        //图文分享转发数据
        Schema::create('wxtj_article_usershares', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('share_scene')->default(0)->comment('');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->timestamps();
            $table->index(['ref_date','share_scene'], 'index1');
        });
        //图文分享转发分时数据
        Schema::create('wxtj_article_usersharehours', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->string('ref_hour', 10)->default('')->comment('数据的小时');
            $table->unsignedInteger('share_scene')->default(0)->comment('');
            $table->unsignedInteger('share_count')->default(0)->comment('分享的次数');
            $table->unsignedInteger('share_user')->default(0)->comment('分享的人数');
            $table->timestamps();
            $table->index(['ref_date','ref_hour','share_scene'], 'index1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wxtj_article_summarys');
        Schema::dropIfExists('wxtj_article_totals');
        Schema::dropIfExists('wxtj_article_userreads');
        Schema::dropIfExists('wxtj_article_userreadhours');
        Schema::dropIfExists('wxtj_article_usershares');
        Schema::dropIfExists('wxtj_article_usersharehours');
    }
}
